<%@page import="com.zkingsoft.constance.SystemConstance"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<c:set var="plat_factory" value="<%=SystemConstance.PLAT_FACTORY%>" />
<c:set var="plat_hotel" value="<%=SystemConstance.PLAT_HOTEL%>" />
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<!-- 视口标签 -->
<meta name="divport"
	content="width=device-width, initial-scale=1, user-scalable=no" />
<!-- 删除苹果默认的工具栏和菜单栏 -->
<meta name="apple-mobile-web-app-capable" content="yes" />
<!-- 设置苹果工具栏颜色 -->
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<!-- 忽略页面中的数字识别为电话，忽略email识别 -->
<meta name="format-detection" content="telphone=no, email=no" />
<!-- 启用360浏览器的极速模式(webkit) -->
<meta name="renderer" content="webkit">
<!-- 避免IE使用兼容模式 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- 针对手持设备优化，主要是针对一些老的不识别divport的浏览器，比如黑莓 -->
<meta name="HandheldFriendly" content="true">
<!-- 微软的老式浏览器 -->
<meta name="MobileOptimized" content="320">
<!-- uc强制竖屏 -->
<meta name="screen-orientation" content="portrait">
<!-- QQ强制竖屏 -->
<meta name="x5-orientation" content="portrait">
<!-- UC强制全屏 -->
<meta name="full-screen" content="yes">
<!-- QQ强制全屏 -->
<meta name="x5-fullscreen" content="true">
<!-- UC应用模式 -->
<meta name="browsermode" content="application">
<!-- QQ应用模式 -->
<meta name="x5-page-mode" content="app">
<!-- windows phone 点击无高光 -->
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
<!-- 适应移动端end -->
<title>订单详情</title>

<link rel="stylesheet" type="text/css"
	href="${path }/resource/css/mobile/base.css" />
<link rel="stylesheet" type="text/css"
	href="${path }/resource/css/mobile/index.css" />
<link rel="stylesheet" type="text/css"
	href="${path }/resource/css/mobile/iconfont/iconfont.css" />
<script type="text/javascript"
	src="${path }/resource/js/plugin/jquery-2.1.4.min.js"></script>
<script type="text/javascript"
	src="${path }/resource/js/systools/AjaxProxy.js"></script>
<script type="text/javascript"
	src="${path }/resource/js/systools/MTools.js"></script>
<script type="text/javascript"
	src="${path }/resource/js/systools/MGrid.js"></script>
<script type="text/javascript"
	src="${path }/resource/plugin/layer/layer.js"></script>
	
<link rel="stylesheet" href="${path }/resource/css/mobile/pickout/pickout.css">
<script type="text/javascript" src="${path }/resource/css/mobile/pickout/pickout.js"></script>
<style type="text/css">
.pk-input,.pk-arrow{
display: none;
}
</style>
</head>
<body>
	<div class="wrap" id="vuediv">
<!-- 		<header class="header"> -->
<!-- 			<h3>订单详情</h3> -->
<!-- 		</header> -->
		<div class="artical_content">
			<div class="artical_title">
				<img src="${path }/resource/images/mobile/orderNum.png"
					class="img_artical" /> <span class="artical_bt">订单编号</span> <span
					class="artical_info">{{order.orderNum}}</span>
			</div>
			<div class="artical_title">
				<img src="${path }/resource/images/mobile/host.png"
					class="img_artical" /> <span class="artical_bt">酒店名</span> <span
					class="artical_info">{{order.hotelName}}</span>
			</div>
			<div class="artical_title">
				<img src="${path }/resource/images/mobile/faicon.png"
					class="img_artical" /> <span class="artical_bt">总数量</span> <span
					class="artical_info">{{order.orderTotalNum}}</span>
			</div>
			<div class="artical_title">
				<img src="${path }/resource/images/mobile/price.png"
					class="img_artical" /> <span class="artical_bt">总损耗</span> <span
					class="artical_info">{{order.orderTotalLoss? order.orderTotalLoss : 0}}</span>
			</div>
			
			<div class="artical_title">
				<img src="${path }/resource/images/mobile/staius.png" class="img_artical" /> <span class="artical_bt">状态</span> 
				
				<span class="artical_info list_stauts" style="text-align: left;" @click="listStauts">{{fmtState}}</span>
				<div class="triangle-down" @click="listStauts"></div>
				
				<div style="display: none;" id="pickout">
				<select id="state" class="state pickout" placeholder="选择订单状态">
					<option :value="ORDER_STATE_CREATE" >已创建</option>
					<option :value="ORDER_STATE_TRANSPORT1">入库运输</option>
					<option :value="ORDER_STATE_STORAGE">已入库</option>
					<option :value="ORDER_STATE_OUT">已出库</option>
					<option :value="ORDER_STATE_TRANSPORT2">出库运输</option>
					<option :value="ORDER_STATE_INSPECTED">已验收</option>
				</select>
				</div>
<!-- 				<ul class="seclist" v-show="showlis"> -->
<!-- 					<li @click="liTap(ORDER_STATE_CREATE)" ><span>已创建</span></li> -->
<!-- 					<li @click="liTap(ORDER_STATE_TRANSPORT1)" ><span>入库运输</span></li> -->
<!-- 					<li @click="liTap(ORDER_STATE_STORAGE)" ><span>已入库</span></li> -->
<!-- 					<li @click="liTap(ORDER_STATE_OUT)" ><span>已出库</span></li> -->
<!-- 					<li @click="liTap(ORDER_STATE_TRANSPORT2)" ><span>出库运输</span></li> -->
<!-- 					<li @click="liTap(ORDER_STATE_INSPECTED)" ><span>已验收</span></li> -->
<!-- 				</ul> -->

			</div>

			<span class="detail_txt">详细信息</span>
			<div class="artical_list_bg">
				<div class="row">
					<div class="col-25">类别</div>
					<div class="col-25">单位</div>
					<div class="col-25">数量</div>
					<div class="col-25">损耗</div>
				</div>
			</div>
			
			<div style="overflow: auto;height:200px;margin-bottom:2.5rem;">
				<div class="row detail_content" v-for="detail in order.linOrderDetails">
					<div class="col-25">
						<span>{{detail.typeName}}</span>
					</div>
					<div class="col-25">
						<span>{{detail.typeUnit}}</span>
					</div>
					<div class="col-25">
						<span>{{detail.detailsNum}}</span>
					</div>
					<div class="col-25">
						<span>{{detail.detailsLoss? detail.detailsLoss : 0}}</span>
					</div>
				</div>
			</div>
			<button type="button" onClick="history.go(-1)" class="iconfont iconfont_fh_btn"></button>
			<button type="button" onClick="submit()" class="btn">确定</button>
		</div>

	</div>
	<script type="text/javascript"
		src="${path }/resource/js/plugin/vue.min.js"></script>
	<script type="text/javascript">
		var vuediv = new Vue({
			el : '#vuediv',
			data : {
				order : new Object(),
				fmtState: '',
				showlis : false,
				ORDER_STATE_CREATE : "<%=SystemConstance.ORDER_STATE_CREATE%>",
				ORDER_STATE_TRANSPORT1: "<%=SystemConstance.ORDER_STATE_TRANSPORT1%>",
				ORDER_STATE_STORAGE: "<%=SystemConstance.ORDER_STATE_STORAGE%>",
				ORDER_STATE_OUT: "<%=SystemConstance.ORDER_STATE_OUT%>",
				ORDER_STATE_TRANSPORT2: "<%=SystemConstance.ORDER_STATE_TRANSPORT2%>",
				ORDER_STATE_INSPECTED: "<%=SystemConstance.ORDER_STATE_INSPECTED%>"
			}
		});
		
		pickout.to({
			el:'.state',
			theme: 'clean',
		});

		$(function() {

			$.ajax({
				type : "post",
				url : "${path}/app/order/getOrderById",
				data : {
					orderId : '${orderId}'
				},
				dataType : 'json',
				async : false,
				success : function(result) {
					// 全局异常处理器发出的错误信息
					if (result.status == "ok") {
						vuediv.$data.order = result.mapInfo.order;
						vuediv.$data.fmtState = fmtOrderState(result.mapInfo.order.orderState);
					} else if (result.status == "user_invalid") {
						layer.msg(result.info, {
							icon : 2,
							time : 1000
						})
						setTimeout('MTools.redirect("${path}/app/user/toLogin")', 1500);
					} else {
						layer.closeAll('loading');
						layer.msg(result.info, {
							icon : 2,
							time : 1000
						});
						return null;
					}
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					layer.closeAll('loading');
					layer.msg("请求遇到问题-错误编号：" + XMLHttpRequest.status, {
						icon : 2
					});
					return null;
				},
			});
		})
		
		function listStauts() {
// 			vuediv.$data.showlis = true;
			$('#pickout > .pk-input').trigger("click");
			
		}
		function chooseState(orderState, fmtState) {
			console.log("orderState",orderState,fmtState);
			vuediv.$data.order.orderState = orderState;
			vuediv.$data.fmtState = fmtState;
		}
		
		function liTap(orderState) {
			
			vuediv.$data.order.orderState = orderState;
			vuediv.$data.fmtState = fmtOrderState(orderState);
			
			vuediv.$data.showlis = false;
		}
		
		function fmtOrderState(orderState) {
			switch(orderState) {
			case "<%=SystemConstance.ORDER_STATE_CREATE%>" : return "已创建";break;
			case "<%=SystemConstance.ORDER_STATE_TRANSPORT1%>" : return "入库运输";break;
			case "<%=SystemConstance.ORDER_STATE_STORAGE%>" : return "已入库";break;
			case "<%=SystemConstance.ORDER_STATE_OUT%>" : return "已出库";break;
			case "<%=SystemConstance.ORDER_STATE_TRANSPORT2%>" : return "出库运输";break;
			case "<%=SystemConstance.ORDER_STATE_INSPECTED%>": return "已验收";break;
			default: return "";
			}
		}
		
		function submit() {
			$.ajax({
				type : "post",
				url : "${path}/app/order/editOrderState",
				data : {
					orderId: vuediv.$data.order.orderId,
			        orderState: vuediv.$data.order.orderState,
				},
				dataType : 'json',
				async : false,
				success : function(result) {
					// 全局异常处理器发出的错误信息
					if (result.status == "ok") {
						layer.msg(result.info, {
							icon : 1,
							time : 1000
						})
						setTimeout('MTools.redirect("${path}/app/order/toOrderList")', 1000)
					} else if (result.status == "user_invalid") {
						layer.msg(result.info, {
							icon : 2,
							time : 1000
						})
						setTimeout('MTools.redirect("${path}/app/user/toLogin")', 1500);
					} else {
						layer.closeAll('loading');
						layer.msg(result.info, {
							icon : 2,
							time : 1000
						});
						return null;
					}
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					layer.closeAll('loading');
					layer.msg("请求遇到问题-错误编号：" + XMLHttpRequest.status, {
						icon : 2
					});
					return null;
				},
			});
		}
	</script>
</body>
</html>
